import { mock }from "mockjs"
import { login } from "./response"

interface IReq {
    body:any
}

mock("user/login","post",(req:IReq) => {
  const { username,password } = JSON.parse(req.body)
  // 请求成功
  if(login(username,password)) {
    return mock({
      errcode:"0",
      errmsg:"success",
      data:{
        username:"pzy",
        wid:"sysadmin" 
      }  
    })
  }
  // 请求失败
  return mock({
    errcode:"999",
    errmsg:"系统内部错误" ,
    data:""
  })
  
})